package svc

import (
	"github.com/zeromicro/go-zero/core/stores/sqlx"
	"user/internal/config"
	"user/models"
)

type ServiceContext struct {
	Config          config.Config
	Conn            sqlx.SqlConn
	UserModel       models.UserModel
	UserExtendModel models.UserExtendModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	conn := sqlx.NewSqlConn(c.DataBase.Driver, c.DataBase.DSN)
	return &ServiceContext{
		Config:          c,
		Conn:            conn,
		UserModel:       models.NewUserModel(conn, c.Cache),
		UserExtendModel: models.NewUserExtendModel(conn, c.Cache),
	}
}
